<?php
	include dirname(dirname(dirname(__FILE__))).'/include/db_connect.php';


	function  updateEmployApply($params,$id){
	
	$sql = "update employ_apply set ";
	$tmp = "";
	foreach ($params as $key => $item) {
		$tmp.=",".$key." = ".$item;
	}
	$sql = $sql.substr($tmp, 1).' where id = '.$id.';';
	$conn = get_db_conn();
	if(mysql_query($sql,$conn)) return true;
	else  return  false;
	
}

	function  updateS_user($params,$id){
	
	$sql = "update s_user set ";
	$tmp = "";
	foreach ($params as $key => $item) {
		$tmp.=",".$key." = ".$item;
	}
	$sql = $sql.substr($tmp, 1).' where id = '.$id.';';
	$conn = get_db_conn();
	if(mysql_query($sql,$conn)) return true;
	else  return false;
	
}

function addUser($params) {
	$col="";
	$val="";
	foreach ($params as $key => $item) {
		$col.=",".$key;
		$val.=",".$item;
	}
	$sql = "insert into user(".substr($col, 1).") values (".substr($val, 1).");";
	$conn = get_db_conn();
	if(mysql_query($sql,$conn))return true;
	else  {
		echo mysql_error();
		return false;
	}
}

	
	function getEmployApplyInfo(){
	$conn=get_db_conn();
	$sql='select ea.*,su.username from employ_apply ea left join s_user su on ea.s_user_id=su.id ;';
	$result=mysql_query($sql,$conn) or die (mysql_error());
	mysql_close($conn);
	return  $result;	
		
}


function getEmployApplyById($apply_id){
	$conn=get_db_conn();
	$sql='select ea.id as ea_id,su.* from employ_apply ea left join s_user su on ea.s_user_id=su.id where ea.id='.$apply_id;
	$result=mysql_query($sql,$conn) or die(mysql_error());
	$row =mysql_fetch_array($result);
	return $row;

}


function statusMap($status){
	switch ($status) {
		case 0:
			return '待审核';
			break;
		case 1:
			return '成功';
			break;
		case 2:
			return '拒绝';
			break;
		default:
			
			break;
	}

}

function timeMap($num){

	switch ($num) {
		case 1:
			return '7:30~10:00';
			break;
		case 2:
			return '10:00~12:30';
			break;
		case 3:
			return '12:30~14:30';
			break;
		case 4:
			return '14:30~16:00';
			break;
		case 5:
			return '16:00~18:30';
			break;
		case 6:
			return '18:30~22:30';
			break;
		default:
			
			break;
	}




}
?>